package com.marst.first.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.marst.first.bean.Role;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface RoleMapper  extends BaseMapper<Role> {

    @Update("update role set is_delete = 1 where id = #{id}")
    void deleteRoleOnLogic(int id);

    @Select("select count(1) from role where name = #{name}")
    int getRoleCountByName(String name);


    @Select("<script>                                              "+
            "SELECT                                                "+
            "	*                                                  "+
            "FROM                                                  "+
            "	role                                               "+
            "WHERE                                                 "+
            "	1 = 1                                              "+
            "<if test=\" name != null and name != '' \">             "+
            "	AND `name` LIKE CONCAT('%','${name}','%' )         "+
            "</if>                                                 "+
            "</script>                                             ")
    List<Role> getRoleList(String name);
}
